****Replication Code for Mixing Messages: How Candidates Vary Their Twitter Rhetoric
*use MixingMessages_Data.dta
xtset states

*H1a and H1b
*Table 4, Model 1
*Total Issue Tweets
xtreg perc_issue_pos2 incumbent competitive quality_opp unopposed open_seat age is_female trump16 republican house senate, fe
*Table 4, Model 2
*Total Tweets
xtreg perc_issue_pos incumbent competitive quality_opp unopposed open_seat age is_female trump16 republican house senate, fe

*H2a and H2b
*Table 4, Model 3
*Total GOTV Tweets
xtreg perc_gotv_pos2 incumbent c.competitive quality_opp unopposed open_seat age is_female trump16 republican house senate, fe
*Table 4, Model 4
*Total Tweets
xtreg perc_gotv_pos incumbent c.competitive quality_opp unopposed open_seat age is_female trump16 republican house senate, fe

*H3A, H3b, H3c, H3d
*Table 5
*Total Tweets
xtreg perc_opp_mention_neg incumbent competitive trailing quality_opp unopposed open_seat age is_female trump16 republican house senate, fe

*Fractional logit robustness checks
fracreg logit perc_gotv_pos2 incumbent c.competitive quality_opp unopposed open_seat age is_female trump16 republican house senate
fracreg logit perc_issue_pos incumbent competitive quality_opp unopposed open_seat age is_female trump16 republican house senate
fracreg logit perc_gotv_pos2 incumbent c.competitive quality_opp unopposed open_seat age is_female trump16 republican house senate
fracreg logit perc_gotv_pos incumbent c.competitive quality_opp unopposed open_seat age is_female trump16 republican house senate
fracreg logit perc_opp_mention_neg incumbent competitive trailing quality_opp unopposed open_seat age is_female trump16 republican house senate

*Table 2
*Total Neutral
gen neutral = fn_total-(fn_pos_s+fn_neg_s)
*Only Issue Tweets
*Positive 
gen only_issue_p=fn_issues_pos_s-fn_mobiss_pos_stanford
*Negative
gen only_issue_n= fn_issues_neg_s-fn_mobiss_neg_stanford
*Neutral
gen only_issue_neutral = fn_issues - fn_mobiss
replace only_issue_neutral = only_issue_neutral-(only_issue_p+only_issue_n)
*Total
gen issue_total = fn_issues - fn_mobiss

*Only GOTV Tweets
*Positive
gen only_gotv_p=fn_gotv_pos_s-fn_mobiss_pos_stanford
*Negative
gen only_gotv_n= fn_gotv_neg_s-fn_mobiss_neg_stanford
*Neutral
gen only_gotv_neutral = fn_gotv - fn_mobiss
replace only_gotv_neutral = only_gotv_neutral-(only_gotv_p+only_gotv_n)
*Total
gen gotv_total = fn_gotv - fn_mobiss

collapse (sum) fn_pos_s (sum) fn_neg_s (sum) neutral (sum) only_issue_p (sum) only_issue_n (sum) only_issue_neutral (sum) issue_total (sum) only_gotv_p (sum) only_gotv_n (sum) only_gotv_neutral (sum) gotv_total (sum) fn_mobiss_pos_s (sum) fn_mobiss_neg_s (sum) fn_mobiss

*Table 3
sum fn_total if house==1
sum fn_total if senate==1
sum fn_total if governor==1

collapse (sum) fn_neg_s (sum) fn_pos_s (sum) fn_total (sum) fn_gotv_neg_s (sum) fn_gotv_pos_s (sum) fn_gotv (sum) fn_issues_neg_s (sum) fn_issues_pos_s (sum) fn_issues (sum) fn_opp_mentions (sum) fn_opp_mentions_neg_s (sum) fn_mobiss (sum) fn_mobiss_pos_stanford (sum) fn_mobiss_neg_stanford, by(position2)



